Professional Documents
Culture Documents
John Harding
July 10, 2008
The Big Idea
User favorites
User uploads
Playlist contents
Video responses
yt = gdata.youtube.service.YouTubeService()
feed = yt.GetYouTubeVideoFeed(uri)
Examples:
http://gdata.youtube.com/feeds/api/videos/?vq=lolcats
http://gdata.youtube.com/feeds/api/videos/?vq=skateboarding&orderby=rating
http://gdata.youtube.com/feeds/api/videos/?vq=music+videos&format=5
YouTube Confidential and Proprietary
Standard Feeds
/feeds/api/standardfeeds/<feed-name>
http://gdata.youtube.com/feeds/api/standardfeeds/recently_featured
http://gdata.youtube.com/feeds/api/standardfeeds/ES/most_viewed
http://gdata.youtube.com/feeds/api/standardfeeds/FR/top_rated?time=today
http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?category=Sports
/feeds/api/videos/<video-id>/related
def _BuildVideoList(dom):
video_entries = dom.getElementsByTagName("entry")
videos_list = []
for video in video_entries:
v = ytvideo.ytvideo()
v.parse_from_xml(video)
videos_list.append(v)
return videos_list
display_videos = GetStandardFeed(server.MOST_VIEWED,
count=1, time='this_week')
display_videos.extend(GetStandardFeed(server.TOP_RATED,
count=1, time='this_week'))
display_videos.extend(GetStandardFeed(server.FEATURED,
count=1, time=None)
_GDataStandardFeedsBasePath = '/feeds/api/standardfeeds'
def GetStandardFeed(self, feed, time='today', count=5):
path = _GDataStandardFeedsBasePath + '/' + feed
if not time is None:
path = path + '?time=' + time
dom = MakeGetRequest(path)
return BuildVideoList(dom)
query = self.request.get('q')
if query is None:
query = 'YouTube APIs'
videos = GetSearchResults(query, category=None)
response.write(video_display.video_list_to_html(videos))
_GDataVideoSearchPath = '/feeds/api/videos‘
def GetSearchResults(self, query, category=None):
path = _GDataVideoSearchPath
if not category is None:
path = path + '/-/' + urllib.quote(category, safe='')
path = path + '?vq=%s' % urllib.quote(query)
dom = MakeGetRequest(path)
return _BuildVideoList(dom)
Differentiate by category
<category scheme='http://…/schemas/2007/subscriptiontypes.cat‘
term='channel'/>
/feeds/api/users/<username>/playlists
<entry>
<title type='text'>Android Demo</title> ...
<yt:position>1</yt:position>
</entry>
<entry>
<title type='text'>A first hand look at building an Android
application</title> …
<yt:position>2</yt:position>
</entry>
/feeds/api/users/<username>/uploads
feed = yt.GetUserFavoritesFeed(
username=‘danielbeast')
uri = '/feeds/api/users/default/uploads'
feed = yt.GetYouTubeVideoFeed(uri)
/feeds/api/…
All relevant data, using plain text instead of HTML
/feeds/base/…
Simple responses with HTML for display
/feeds/mobile/…
Most compact responses for low-bandwidth mobile devices.
https://www.google.com/accounts/AuthSubRequest?
next=http://your.app.com/login_complete
scope=http://gdata.youtube.com
session=1&secure=0
User will be sent back to your site with a one-time use token
http://your.app.com/login_complete?token=<one-time-token>
Direct Upload
For installed applications
For web apps, if you have (or want) a copy of the video
Browser Upload
For web apps only
Your app controls the metadata
User uploads the video directly to YouTube
<entry>
...
<media:group>
<media:category scheme='…/schemas/2007/developertags.cat'>
my_user_id=john
</media:category>
<media:category scheme=‘…/schemas/2007/developertags.cat'>
type=test
</media:category>
</media:group>
</entry>
--Arbitrary-String
Content-Type: application/atom+xml
<entry>…</entry>
--Arbitrary-String
Content-Type: video/mp4
Content-Transfer-Encoding: binary
<entry> …
<media:category scheme=http://.../schemas/2007/developertags.cat>
my_user_id=john </media:category>
… </entry>
Step 4: Receive upload URL and token
<?xml version='1.0' encoding='UTF-8'?>
<response>
<url>http://uploads.gdata.youtube.com/action/FormDataUpload/AIw…<url>
<token>AIwbFAS…b9gtLCYjoE-</token>
</response>
YouTube Confidential and Proprietary
Browser Upload Example
Step 5: Display upload form
<form action="http://uploads.gdata.../FormDataUpload/AIw...?
nexturl=http://mysite.com/upload_complete“
method="post“ enctype="multipart/form-data">
Video File: <input type="file" name="file"/>
<input type="hidden" name="token" value="AIw…YjoE-"/>
<input type="submit"/>
</form>